<template>
    <div :class="{'hidden': hidden}">
        <div class="pagination">
            <el-pagination 
                background 
                layout="prev, pager, next" 
                :total="total"
                :page-count="pagerCount"
                :page-size.sync="pageSize"
                :current-page.sync="currentPage"
                @current-change="handleCurrentChange"
                >
            </el-pagination>
        </div>
    </div>
</template>
<script>
    export default {
        name: "CustomPagination",
        props: {
            // 数据总数
            total: {
                type: Number,
                default: 0
            },
            // 当前页
            page: {
                type: Number,
                default: 1
            },
            // 每个个数
            pageSize: {
                type: Number,
                default: 10
            },
            // 移动端页码按钮的数量端默认值5
            pagerCount: {
                type: Number,
                default: document.body.clientWidth < 992 ? 5 : 7
            },
            hidden: {
                type: Boolean,
                default: true
            }
        },
        data() {
            return {
                
            };
        },
        computed: {
            currentPage: {
                get() {
                    return this.page
                },
                set(val) {
                    this.$emit('update:page', val)
                }
            },
        },
        methods: {
            handleCurrentChange: function (val) {
                this.$emit("update:page", val);
                this.$emit('pagination')
            }
        }
    }
</script>
<style>
.pagination{
    display:flex;justify-content:center;color:#888;margin:0.6rem 0 0;font-size:0.16rem;
}

.el-pagination.is-background .el-pager li:not(.disabled).active{
    background-color: #017CBA;
    color: #FFF;
}
.el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev{
    background-color: #fff;
    border-radius: 5px;
    min-width: 0.8rem;
    height: 0.5rem;
    line-height: 0.5rem;
    color: #017CBA;
}
.el-pagination.is-background .el-pager li{
    width: 0.5rem;
    height: 0.5rem;
    line-height: 0.5rem;
    background: #FFFFFF;
    text-align: center;
    font-size: 0.16rem;
    border-radius: 5px;
    font-weight: 400;
}
.hidden{
    display: none
}
</style>